<#include "/includes/vars.inc"> 
<@pp.dropOutputFile />
<#list entities.entity as entity>
    <#assign entityName = entity.@name>
    <#assign fileName = "${javaDir}${packageDir}/service/"+entity.@name?cap_first+"Service.java">
    <#if !pp.outputFileExists(fileName)>
            <@pp.changeOutputFile name="${fileName}" />
		
package ${project.@rootPackage}.service;

import ${project.@rootPackage}.dao.${entityName}Dao;
import ${project.@rootPackage}.domain.${entityName};
<#if entity.column.@mode?seq_contains("AUTO")>
import java.util.List;
import org.springframework.transaction.annotation.Transactional;
import org.apache.commons.lang.Validate;
</#if>
import java.util.logging.Level;
import java.util.logging.Logger;
import org.springframework.stereotype.Service;

/**
 * Service class for entity ${entity.@name}
 * <#if project.@author[0]??>@author ${project.@author}</#if>
 */
@Service
public class ${entityName}Service extends ${entityName}ServiceBase {
	
	private static final Logger logger = Logger.getLogger("${entityName}");

    <#if entity.column.@mode?seq_contains("AUTO") >
    @Transactional
    @Override
    public boolean create(${entityName} ${entityName?uncap_first}) {
        Validate.notNull(${entityName?uncap_first});
        <#list entity.column as column>
        	<#if column.@mode="AUTO">
        		<#if column.@type="String">
        ${entityName?uncap_first}.set${column.@name?cap_first}("autoGeneratedString");
        		<#elseif column.@type="Date">
        ${entityName?uncap_first}.set${column.@name?cap_first}(new java.util.Date());
        		<#elseif column.@type="Boolean">
        ${entityName?uncap_first}.set${column.@name?cap_first}(false);
        		<#else>
       	${entityName?uncap_first}.set${column.@name?cap_first}(null);
       			</#if>
       		</#if>
        </#list>
        return getDao().create(${entityName?uncap_first});
    }
     </#if>
        
}
    </#if>
</#list>